package net.begincode.controller;

import net.begincode.handler.ServerHandler;
import net.begincode.model.Server;
import net.begincode.param.ServerParam;
import net.begincode.support.AuthPassport;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by saber on 2017/9/25.
 */
@RequestMapping("server")
@Controller
public class ServerController {

    @Resource
    private ServerHandler serverHandler;

    @AuthPassport
    @ResponseBody
    @RequestMapping("list")
    public Object listServer() {
        return serverHandler.listServer();
    }

    @AuthPassport
    @ResponseBody
    @RequestMapping("delete")
    public Object deleteServer(Integer serverId) {
        return serverHandler.deleteServer(serverId);
    }


    @AuthPassport
    @RequestMapping("update")
    public String updateServer(ServerParam serverParam, Integer serverId) {
        Server server = serverParam.getServer();
        serverHandler.updateServer(server, serverId);
        return "server";
    }

    @AuthPassport
    @RequestMapping("insert")
    public String insertServer(ServerParam serverParam) {
        Server server = serverParam.getServer();
        serverHandler.insertServer(server);
        return "server";
    }


}
